<?php

namespace App\Exports;

use App\Models\Admin\User;
use App\Models\Admin\TeamAward;
use Maatwebsite\Excel\Concerns\FromCollection;

class UsersExport implements FromCollection
{
    private $data;

    public function __construct($data,$storeId)
    {
        $this->data = $data;
        $this->storeId = $storeId;
    }

    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {   
        if($this->storeId == 0){
            $awardName = "富利指数";
        }else{
            $teamAward = new TeamAward;
            $team = $teamAward->awardGold($this->storeId);
            $awardName = $team->award_name;
        }
        
        $title = ["店铺ID", "用户ID", "姓名", "手机", "会员昵称", "微信", "推荐人ID", "推荐人昵称", "合伙人ID", "合伙人昵称", "余额", "积分", $awardName, "等级", "代数","是否为加美官微老用户", "是否关注", "成为合伙人时间", "注册时间"];
        $data = $this->data;

        return collect([
            $title,
            $data
        ]);
    }
}
